package com.zx.product.controller;


import com.zx.product.entity.Product;
import com.zx.product.services.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/products")
public class ProductController {

    @Autowired
    private ProductService productService;


    /**
     * 根据id获取商品信息
     * @param productId
     * @return
     */

    @GetMapping("/getById/{id}")
    public Product getProductById(@PathVariable(name = "id") Long productId){
        Product product = productService.getProductById(productId);
        System.out.println("hello");
        return product;
    }
}
